<template>
  <div class="l-load-views">
    <div class="lr-home__main">
      <l-loading></l-loading>
      <div class="pd-16" >{{$t('Logining...')}}</div>
    </div>
    <div class="lr-home__footer" style="position: absolute">
      <a :href="appConfig.url" target="_blank">{{ appConfig.company }}</a>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {};
  },
  created() {
    this.init();
  },
  computed: {
    api(){
      return window.$api.other.sso
    },
  },
  methods: {
    async init(){
      const info = this.$route.query.info
      if(info){
        //console.log(info);
        const infoObj = JSON.parse(info);
        const res = await this.$awaitWraper(this.api.login(infoObj))
        if(res){
          this.$store.dispatch("organization/user/loginToken",{token:res.ssologin_token} )
          this.$store.commit('app/SET_ISFIRSTLOAD',true)
          this.$router.push({ path: infoObj.realUrl, replace: true})
        }
        else{
          // Login失败
          this.$router.push({ path: "/login", replace: true})
        }
      }
      else{
        this.$router.push({ path: "/login", replace: true})
      }
    }
  },
};
</script>
